package com.zhaojun.netty.msgpack;

import org.msgpack.MessagePack;
import org.msgpack.template.Templates;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class MsgPackDemo {
    public static void main(String[] args) throws Exception {
        MessagePack messagePack=new MessagePack();
       /* List<String> list=new ArrayList<String>();
        list.add("hello1");
        list.add("hello2");
        list.add("hello3");
        list.add("hello4");*/
       List<Person> list=new ArrayList<Person>();
        for (int i = 0; i <10 ; i++) {
            Person person=new Person();
            person.setId(i);
            person.setName("name"+i);
            list.add(person);
        }

        byte[] bytes = messagePack.write(list);

        System.out.println(bytes.length);

        List<Person> list2 = (List<Person>) messagePack.read(bytes/*, Templates.tList(Templates.TString)*/);
        System.out.println(list2);
    }
}
